A 0
B 0
C 0
D 810
E 0
F 0
G 0
H 294
I 573
J 244
K 0
L 0
M 0
N 0
O 481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32
Kerry Back
Here are the trades:
A 0
B 0
C 0
D 810
E 0
F 0
G 0
H 294
I 573
J 244
K 0
L 0
M 0
N 0
O 481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32
sellall = (ranks>10) & (positions !=0)
sellallamounts = positions
trades = - np.where(sellall, sellallamounts, 0)
sellsome = (ranks<=10) & (weights>0.2)
sellsomeamounts = (equity*(weights-0.2)/prices).astype(int)
trades -= np.where(sellsome, sellsomeamounts, 0)
trades = pd.Series(trades, index=ranks.index)
cash -= (trades*prices).sum()Here are the trades:
A 0
B 401
C 0
D -40
E 0
F 0
G 0
H 0
I 0
J -6
K 0
L 0
M 0
N 21
O -481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32
Here are the ranks that generated the trades:
A 19
B 1
C 24
D 8
E 23
F 17
G 26
H 2
I 4
J 10
K 16
L 13
M 21
N 3
O 12
P 7
Q 11
R 15
S 6
T 14
U 18
V 25
W 9
X 5
Y 20
Z 22
Name: 0, dtype: int64